package com.zhoutian.server.config.druid;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;

/**
 * Druid配置类
 */
@Configuration
public class DruidConfig {

    // 配置数据源
    @ConfigurationProperties(prefix = "spring.datasource")
    @Bean
    public DataSource druidSource() {
        return new DruidDataSource();
    }

    @PostConstruct
    public void setProperties() {
        System.setProperty("druid.mysql.usePingMethod", "false");
    }
}
